package com.wyx.easyExcel.easyExcelHandler;

import com.alibaba.excel.write.handler.AbstractRowWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
import com.wyx.easyExcel.easyExcelPojo.RowObj;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;

import java.util.List;

/**
 * @author 吴宇~
 * @motto 我亦无他，唯手熟尔。
 * @edition jdk1.8
 * @reflection 0-1 喧闹任其喧闹，自由我自为之，我自风情万种，与世无争。
 * @date 2024/12/08/7:09
 * @target 心若有所向往，何惧道阻且长
 */
public class WeeklySupplyStrategyDataHeightHandler extends AbstractRowWriteHandler {
    private List<RowObj> heightList;

    public WeeklySupplyStrategyDataHeightHandler(List<RowObj> heightList) {
        this.heightList = heightList;
    }

    @Override
    public void afterRowCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Integer relativeRowIndex, Boolean isHead) {
        // 设置行高，单位为1/256个点
        int rowNum = row.getRowNum();
        for (int i = 0; i < heightList.size(); i++) {
            RowObj rowObj = heightList.get(i);
            if (rowNum == rowObj.getRowIndex()){
                row.setHeight(rowObj.getRowHeight());
            }
        }
    }
}
